package ws.jdbc.concurrent.driver.sqlserver.tds;

import ws.jdbc.concurrent.driver.sqlserver.tds.datastreamtypes.B_VARCHAR;
import ws.jdbc.concurrent.driver.sqlserver.tds.datatypes.TYPE_INFO;

/**
 * Column data information as received in a {@code COLMETADATA} token.
 *
 * @author Wilson Santos, 36228 <wilson.santos@ua.pt>
 */
public class ColumnData {

  /**
   * The user-defined data type of the column.
   */
  private int userType;
  /**
   * Bit flags.
   */
  private short flags;
  /**
   * Column type description.
   */
  private TYPE_INFO typeInfo;
  /** 
   * Column name.
   */
  private B_VARCHAR colName;

  public ColumnData(int userType, short flags, TYPE_INFO typeInfo, B_VARCHAR colName) {
    this.userType = userType;
    this.flags = flags;
    this.typeInfo = typeInfo;
    this.colName = colName;
  }

  public TYPE_INFO getTypeInfo() {
    return typeInfo;
  }

  public String getColName() {
    return colName.toString();
  }

  @Override
  public String toString() {
    return "ColumnInfo{"
            + "\n  colName=" + colName
            + "\n  type=" + typeInfo
            + "\n}";
  }
}
